package cn.lmxdev.ptms.handler.exception;

import cn.lmxdev.ptms.bean.exception.BizException;
import cn.lmxdev.ptms.bean.vo.ResponseVo;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.core.annotation.Order;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
@Order(1)
public class CustomExceptionHandler {
    /* 自定义异常处理器 */
    @ExceptionHandler(value = BizException.class)
    public ResponseVo<Object> bizExceptionHandler(HttpServletRequest request, HttpServletResponse response, BizException e) {
        response.setStatus(HttpServletResponse.SC_OK);
        return new ResponseVo<>().setCode(e.getCode()).setMsg(e.getMsg());
    }
}
